package com.ieasy.module.system.web.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.ieasy.basic.model.Msg;
import com.ieasy.basic.util.cons.Const;
import com.ieasy.module.common.web.action.BaseController;
import com.ieasy.module.system.service.IQuotientService;
import com.ieasy.module.system.web.form.QuotientForm;

@Controller
@RequestMapping("/admin/system/quotient")
public class QuotientAction extends BaseController {

	@Autowired
	private IQuotientService quotientService ;
	
	@RequestMapping("/quotient_form_UI.do")
	public String quotient_form_UI(QuotientForm form, Model mode){
		if(null != form.getPositionId() && !"".equals(form.getPositionId())) {
			mode.addAttribute("positionId", form.getPositionId()) ;
		}
		return Const.SYSTEM + "quotient_form_UI" ;
	}
	
	
	@RequestMapping("/get.do")
	@ResponseBody
	public QuotientForm get(QuotientForm form){
		return this.quotientService.get(form) ;
	}
	
	@RequestMapping("/add.do")
	@ResponseBody
	public Msg add(@RequestBody List<QuotientForm> forms){
		String jsonStr = JSON.toJSONString(forms);
		List<QuotientForm> QuotientForms = JSON.parseArray(jsonStr, QuotientForm.class);  
		return this.quotientService.addList(QuotientForms) ;
	}
	
	@RequestMapping("/list.do")
	@ResponseBody
	public List<QuotientForm> list(QuotientForm form){
		return this.quotientService.list(form) ;
	}
	
	
}
